
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/dist/query/react";

//入库操作请求API
export const quartzApi = createApi({
    reducerPath: 'quartzApi',
    //设置基本请求路径
    baseQuery: fetchBaseQuery({
        baseUrl: window.app
    }),
    tagTypes: ['quartzApi'],//定义标签
    endpoints(build) {
        return {

            getquartzstartexcute: build.query({
                query: (data) => ({
                    url: 'Quartz/AddandStartJob',
                    method: 'GET',
                    params: data,
                }),
                transformResponse(baseQuery) {
                    return baseQuery;
                },

            }),
            // getquartzdelte: build.query({
            //     query: (data) => ({
            //         url: 'Quartz/DeleteJob',
            //         method: 'GET',
            //         params: data,
            //     }),
            //     transformResponse(baseQuery) {
            //         return baseQuery;
            //     },

            // }),
            //删除一条商品入库记录
            deletquartzremove: build.mutation({
                query(jobname) {
                    return {
                        url: `Quartz/RemoveJob?key=${jobname}`,
                        method: 'DELETE',

                    };
                },
                transformResponse(baseQuery) {
                    return baseQuery.data;

                },
                invalidatesTags: ['quartzApi']//定义标签，一旦修改数据，则会使该标签失效
            }),
        }
    }
});


//导出钩子函数给外部使用，自动生成hooks的名称为`use(Endpoint_name)Query`
export const { useGetquartzstartexcuteQuery, useDeletquartzremoveMutation } = quartzApi;